from flask_socketio import emit

# NOTE!
# distributed -> managed  must != webclient -> managed
# because managed received events from them.

# distributed -> manager
edm_model_detail_list_report = 'edm_model_detail_list_report'
edm_model_state_report = 'edm_model_state_report'
edm_model_info_report = 'edm_model_info_report'
edm_model_error_report = 'edm_model_error_report'
edm_model_start_releasing_report = 'edm_model_start_releasing_report'
edm_model_upload_state_report = 'edm_model_upload_state_report'

# manager -> distributed
emd_model_state_request = 'model_state_request'
emd_model_detail_list_request = 'model_detail_list_request'
emd_model_start_uploading = 'model_start_uploading'
emd_model_start_releasing = 'model_start_releasing'

# webclient -> manager
ewm_model_list_request = 'model_list_request'
ewm_model_detail_list_request = 'model_detail_list_request'
ewm_model_start_releasing = 'model_start_releasing'
ewm_model_start_uploading = 'model_start_uploading'

# manager -> webclient
emw_model_list_report = 'model_list_report'
emw_model_detail_list_report = 'model_detail_list_report'
emw_model_state_report = 'model_state_report'
emw_model_state_list_report = 'model_state_list_report'
emw_model_error_report = 'model_error_report'
emw_info_report = 'info_report'
emw_model_upload_state_report = 'model_upload_state_report'


class DIO:
    room_web = 'webclient'
    room_distributed = 'distributed'

    def __init__(self):
        ...

    def web_send(self, evt: str, data):
        emit(evt, data, to=self.room_web)

    def distributed_send(self, evt: str, data):
        emit(evt, data, to=self.room_distributed)

    def send(self, evt: str, data, to):
        emit(evt, data, to=to)


io = DIO()
